package com.myapplication.viewpager;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/12.
 */
public class ChangableViewPager extends PagerAdapter{
    List<View> pagerView = new ArrayList<>();

    public ChangableViewPager(List<View> pagerView) {
        this.pagerView = pagerView;
    }

    @Override
    public int getCount() {
        return pagerView.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(pagerView.get(position));
        return pagerView.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
         container.removeView(pagerView.get(position));
    }



    @Override
    public int getItemPosition(Object object) {
        return super.getItemPosition(object);
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
}
